// Copyright (C) 2014 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: Compound Assignment Operator calls PutValue(lref, v)
es5id: S11.13.2_A6.2_T1
description: >
    Evaluating LeftHandSideExpression lref returns Reference type; Reference
    base value is an environment record and environment record kind is
    declarative environment record. PutValue(lref, v) uses the initially
    created Reference even if a more local binding is available.
    Check operator is "x /= y".
flags: [noStrict]
---*/

function Test() {
    function testCompoundAssignment() {
      var x = 15;
      var innerX = (function() {
        x /= (eval("var x = 2;"), 3);
        return x;
      })();

      if (innerX !== 2) {
        throw new Test262Error('#1: innerX === 2. Actual: ' + (innerX));
      }
      if (x !== 5) {
        throw new Test262Error('#2: x === 5. Actual: ' + (x));
      }
    }
    testCompoundAssignment();
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}
